package com.xtayfjpk.zookeeper.test.master_workers.watcher;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;

import com.xtayfjpk.zookeeper.test.master_workers.Master;

public class TasksChangeWatcher implements Watcher {
	private Master master;
	
	public TasksChangeWatcher(Master master) {
		this.master = master;
	}
	
	
	@Override
	public void process(WatchedEvent event) {
		if(event.getType() == EventType.NodeChildrenChanged) {
			assert "/tasks".equals(event.getPath());
			
			master.monitorTasks();
		}
	}

}
